<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Category;

class CategoryController extends Controller
{

    
    public function index(Request $request){
        $data = collect([0=>'全部'])->union(Category::where('overt', 1)->orderBy('rank','asc')->pluck('name','id'))->all();
        $list = [];
        foreach( $data  as $id=>$item){
            $list[] = ['id'=>$id,'name'=>$item];
        }
        return response()->json($list);
    }
}
